# 序列  列表和元组 字符串
ed = ['ED', 21]
print(ed[0], ed[1], ed[-1], ed[-2], len(ed))  # ED 21 21 ED 2

# index
greeting = 'Hello'
print(greeting[0])  # H
print(greeting[-1])  # o

# slice
tag = '<a href="http://www.python.org">Python web site</a>'
print(tag[9:30])
print(tag[32:-4])

#
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
print(numbers[3:6])  # [4, 5, 6]
print(numbers[0:1])  # [1]

#
print(numbers[7:10])  # [8, 9, 10]
print(numbers[7:])  # [8, 9, 10]
print(numbers[-3:])  # [8, 9, 10]
#
print(numbers[:3])  # [1, 2, 3]
print(numbers[0:3])  # [1, 2, 3]
#
numbers_copy = numbers[:]
numbers_copy[0] = 999;
print(numbers[0], numbers_copy[0])  # 1 999
#
print(numbers[0:10:1])  # [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
print(numbers[0:10:2])  # [1, 3, 5, 7, 9]
print(numbers[::2])  # [1, 3, 5, 7, 9]
print(numbers[::-1])  # [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
print(numbers[8:3:-1])  # [9, 8, 7, 6, 5]

#
u = "http://www.somedomainname.com"
domain = u[11:-4]
print(domain)  # somedomainname
#
